package cn;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Locale;
/**
 * description:
 * author:zcx
 * lenovo
 * 时间：2022.01.17.17.32
 */
public class Javacj {
    //统计Java文件多少行
    public static long rows=0;
    public static long filecount=0;
    public static void main(String[] args)  {
     count(new File("D:\\JavaStudy"));
        System.out.println(rows);
        System.out.println(filecount);
    }
public static void count(File file){
if(file.isDirectory()){
    for(File t:file.listFiles()){
        if(t.isDirectory()){
            count(t);
        }else if(t.isFile()&& t.getName().toLowerCase(Locale.ROOT).endsWith(".java")){
         rows+=rows(t);
         System.out.printf("%s(%d)[%3$tF %<tT]%n", t.getAbsolutePath(), rows(t), t.lastModified());
         ++filecount;
        }
    }
}
}
    public static long rows(File file){
        long rows = 0;
        try {
            var br = new BufferedReader(new FileReader(file));
            rows = br.lines().count();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return rows;
    }
}
